// Copyright (c) 2024 CHANGLEI. All rights reserved.

import 'package:charts_grasp/src/chart/chart_series/series.dart';
import 'package:charts_grasp/src/chart/chart_series/series_renderer_properties.dart';
import 'package:charts_grasp/src/chart/chart_series/xy_data_series.dart';
import 'package:flutter/material.dart';

export 'package:charts_grasp/src/core/core.dart' show DataMarkerType, TooltipAlignment;

@immutable
class InteractiveTooltip {
  const InteractiveTooltip({
    this.enable = true,
    this.color,
    this.borderColor,
    this.borderWidth = 0,
    this.borderRadius = 5,
    this.arrowLength = 7,
    this.arrowWidth = 5,
    this.format,
    this.connectorLineColor,
    this.connectorLineWidth = 1.5,
    this.connectorLineDashArray,
    this.decimalPlaces = 3,
    this.canShowMarker = true,
    this.textStyle,
  });

  final bool enable;

  final Color? color;

  final Color? borderColor;

  final double borderWidth;

  final TextStyle? textStyle;

  final double borderRadius;

  final double arrowLength;

  final double arrowWidth;

  final String? format;

  final double connectorLineWidth;

  final Color? connectorLineColor;

  final List<double>? connectorLineDashArray;

  final int decimalPlaces;

  final bool canShowMarker;

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) {
      return true;
    }
    if (other.runtimeType != runtimeType) {
      return false;
    }

    return other is InteractiveTooltip &&
        other.enable == enable &&
        other.color == color &&
        other.borderColor == borderColor &&
        other.borderWidth == borderWidth &&
        other.borderRadius == borderRadius &&
        other.arrowLength == arrowLength &&
        other.arrowWidth == arrowWidth &&
        other.format == format &&
        other.connectorLineColor == connectorLineColor &&
        other.connectorLineWidth == connectorLineWidth &&
        other.connectorLineDashArray == connectorLineDashArray &&
        other.decimalPlaces == decimalPlaces &&
        other.canShowMarker == canShowMarker &&
        other.textStyle == textStyle;
  }

  @override
  int get hashCode {
    final List<Object?> values = <Object?>[
      enable,
      color,
      borderColor,
      borderWidth,
      borderRadius,
      arrowLength,
      arrowWidth,
      format,
      connectorLineColor,
      connectorLineWidth,
      connectorLineDashArray,
      decimalPlaces,
      canShowMarker,
      textStyle,
    ];
    return Object.hashAll(values);
  }
}

class ChartPointInfo {
  double? markerXPos;

  double? markerYPos;

  String? label;

  int? dataPointIndex;

  CartesianSeries<dynamic, dynamic>? series;

  SeriesRendererDetails? seriesRendererDetails;

  CartesianChartPoint<dynamic>? chartDataPoint;

  double? xPosition;

  double? yPosition;

  Color? color;

  String? header;

  double? lowYPosition;

  double? highXPosition;

  double? highYPosition;

  double? openYPosition;

  double? closeYPosition;

  double? openXPosition;

  double? closeXPosition;

  double? minYPosition;

  double? maxYPosition;

  double? lowerXPosition;

  double? upperXPosition;

  double? lowerYPosition;

  double? upperYPosition;

  double? maxXPosition;

  late int seriesIndex;
}
